//
//  SolutionViewController.m
//  AdvertisementI
//
//  Created by mac on 16/5/19.
//  Copyright © 2016年 Apple inc. All rights reserved.
//

#import "SolutionViewController.h"

#import "SolutionViewControllerCell.h"
#import "ZLSoloViewController.h"
#import "netWork.h"
#import "UIImageView+WebCache.h"
#import "MAin.h"
@interface SolutionViewController ()
@property(nonatomic,assign)NSUserDefaults *userdefaults1;
@end

@implementation SolutionViewController
-(void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:19],
       NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    //加载自定义视图
    _imageArr = [[NSMutableArray alloc]init];
    [netWork scroll:^(NSArray *arr) {
        [_imageArr setArray:arr];
        [_tableView reloadData];
    } type:@"app_loadTab2"];
    
    
    UITableView * table = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
    [self.view addSubview:table];
    table.delegate = self;
    table.dataSource = self;
    table.rowHeight = 60;
    _tableView =table;
    [table registerNib:[UINib nibWithNibName:@"SolutionViewControllerCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    ZLSoloViewController *vc= [[ZLSoloViewController alloc]init];
     MAin *main =[_imageArr objectAtIndex:indexPath.row ];
    vc.myTitle = main.name;
    vc.hidesBottomBarWhenPushed = YES;
    NSInteger count = 0;
    count = indexPath.row;
//    NSString * string = nil;
        if (count ==1) {
           vc.string  = @"http://47.88.76.185/John2.html";
        }else if (count==2){
             vc.string = @"http://47.88.76.185/Shokley.html" ;
        }else if (count==3){
             vc.string =@"http://47.88.76.185/Stanford_University.html" ;
        }else if (count==4){
             vc.string = @"http://47.88.76.185/Steve_Wozniak.html";
        }else if (count==5){
           vc.string = @"http://47.88.76.185/sx/html2/FEP.html";
        }else if (count==6){
             vc.string = @"http://47.88.76.185/terman.html";
        }else if (count==7){
            vc.string = @"http://47.88.76.185/sx/htm/cable.html";
        }else if (count==8){
             vc.string = @"http://47.88.76.185/sx/htm/Dieletric.html";
        }else if (count==9){
             vc.string = @"http://47.88.76.185/sx/htm/Metal.html";
        }else if (count==10){
            vc.string = @"http://47.88.76.185/sx/htm/SqlServer.html";
        }else if (count==11){
             vc.string = @"http://47.88.76.185/sx/htm/Switch.html";//http://47.88.76.185/sx/html2/电子元器件.html
        }else if (count==12){
            vc.string = @"http://47.88.76.185/sx/html/Arthur.html";
        }else if (count==13){
            vc.string = @"http://47.88.76.185/sx/htm/Switch.html";
        }else if (count==14){
            vc.string = @"http://47.88.76.185/sx/html/DMOS.html";
        }else if (count==15){
            vc.string = @"http://47.88.76.185/sx/html/DRAMS.html";//http://47.88.76.185/sx/html2/电子元器件.html
        }else{
             vc.string = @"http://47.88.76.185/sx/htm/Metal.html";//http://47.88.76.185/sx/html2/硅晶片.html
        }
        
    
    [self.navigationController pushViewController:vc animated:YES];
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _imageArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SolutionViewControllerCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    MAin *main =[_imageArr objectAtIndex:indexPath.row ];
    cell.headImag.frame = CGRectMake(15, 15, (self.view.frame.size.width-30)*1/3, cell.frame.size.height-20);//
    //    [manger POST:@"http://192.168.0.105
    [cell.headImag sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://47.88.76.185:8080/Test/%@",main.Imagelogo]]];
    cell.nameLabel.frame = CGRectMake(cell.headImag.frame.size.width+15+50, 15, cell.frame.size.width-30-cell.headImag.frame.size.width, cell.frame.size.height-20);
    //    NSLog(@"----------------%@",main.Imagelogo);
    cell.nameLabel.text = main.name;
    cell.nameLabel.font = [UIFont systemFontOfSize:18];
    cell.nameLabel.textColor = [UIColor blueColor];
    cell.nameLabel.lineBreakMode = NSLineBreakByCharWrapping;
    
    //
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
